package com.seeyon.ctp.rest.resources;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.seeyon.apps.collaboration.api.CollaborationApi;
import com.seeyon.apps.collaboration.api.CollaborationApiImpl;
import com.seeyon.apps.collaboration.bo.ColParam;
import com.seeyon.apps.collaboration.constants.ColConstant;
import com.seeyon.ctp.common.AppContext;
import com.seeyon.ctp.common.log.CtpLogFactory;
import com.seeyon.ctp.common.template.manager.TemplateManager;
import com.seeyon.ctp.util.JDBCAgent;
import com.seeyon.ctp.util.annotation.Inject;
import com.seeyon.ctp.util.annotation.PluginQualifier;
import com.seeyon.ctp.util.annotation.RestInterfaceAnnotation;
import org.apache.commons.logging.Log;

import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

/**
 * @author Guoan
 * @date 2024/4/24 - 17:48
 * 设备管理对接cop
 */
@Path("device")
@Consumes({"application/json"})
@Produces({"application/json"})
public class DeviceResource extends BaseResource{
    private static Log log = CtpLogFactory.getLog(DeviceResource.class);

    private CollaborationApi collaborationApi = (CollaborationApi) AppContext.getBean("collaborationApi");
    public DeviceResource() {
    }

    /**
     * 测试重新提交
     * @param jsonObject  json数据
     * @return 返回信息
     * @throws Exception
     */
    @POST
    @Produces({"application/json"})
    @Path("qualityplan")
    @RestInterfaceAnnotation
    public Response separateSave(JSONObject jsonObject) throws Exception {
        log.info("质量计划传来的参数=" + jsonObject.toString());

        Long templateId = jsonObject.getLong("templateId");//模板id
        Long senderId = jsonObject.getLong("senderId");//发送人id
        Long formMasterId = jsonObject.getLong("formMasterId"); //数据id
        Long parentSummaryId = jsonObject.getLong("parentSummaryId");//协同代办id
        Long newSumamryId = jsonObject.getLong("newSumamryId");//协同代办id
        log.info("templateId=" + templateId + ",senderId=" + senderId + ",formMasterId=" + formMasterId + ",parentSummaryId=" + parentSummaryId + "" +
                ",newSumamryId=" + newSumamryId);
        ColParam colParam = new ColParam();
        colParam.setSkipStart(true);
        log.info("colParam=" + colParam.getSkipStart());
        collaborationApi.transSendColl(ColConstant.SendType.resend,templateId,senderId,formMasterId,null,newSumamryId,colParam);
        return this.success("ok");
    }



}
